/*-------------------------------------------------------------------------
 *
 * replslotdesc.c
 *	  复制/slot.c 的 rmgr 描述例程
 *
 * Portions Copyright (c) 2015, PostgreSQL Global Development Group
 *
 *
 * IDENTIFICATION
 *	  src/backend/access/rmgrdesc/replslotdesc.c
 *
 *-------------------------------------------------------------------------
 */
#include "postgres.h"
#include "replication/slot_xlog.h"


void replslot_desc(StringInfo fc_buf, XLogReaderState *fc_record)
{
	char	   *fc_rec = XLogRecGetData(fc_record);
	uint8		fc_info = XLogRecGetInfo(fc_record) & ~XLR_INFO_MASK;

	switch (fc_info)
	{
		case XLOG_REPLSLOT_UPDATE:
			{
				ReplicationSlotPersistentData* fc_xlrec;

				fc_xlrec = (ReplicationSlotPersistentData *) fc_rec;

				appendStringInfo(fc_buf, "of slot %s with restart %X/%X and xid %u confirmed to %X/%X",
						NameStr(fc_xlrec->name),
						(uint32)(fc_xlrec->restart_lsn>>32), (uint32)(fc_xlrec->restart_lsn),
						fc_xlrec->xmin,
						(uint32)(fc_xlrec->confirmed_flush>>32), (uint32)(fc_xlrec->confirmed_flush));

				break;
			}
		case XLOG_REPLSLOT_DROP:
			{
				xl_replslot_drop *fc_xlrec;

				fc_xlrec = (xl_replslot_drop *) fc_rec;

				appendStringInfo(fc_buf, "of slot %s", NameStr(fc_xlrec->name));

				break;
			}
	}
}

const char * replslot_identify(uint8 fc_info)
{
	switch (fc_info)
	{
		case XLOG_REPLSLOT_UPDATE:
			return "UPDATE";
		case XLOG_REPLSLOT_DROP:
			return "DROP";
		default:
			return NULL;
	}
}


